package com.Controller;

import com.pojo.SysSupplier;
import com.service.supplier.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping(value = "/supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    @RequestMapping(value = "/list")
    public String list(Model model, String supName, @RequestParam(value = "pageNo",defaultValue = "1") int pageNo){
        int pageIndex = (pageNo-1) * 5;
        List<SysSupplier> list = supplierService.list(supName,pageIndex);
        int pageCount = supplierService.count(supName);
        model.addAttribute("pageCount",pageCount);
        model.addAttribute("list",list);
        model.addAttribute("supName",supName);
        return "supplier/list";
    }
}
